﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MvcMall.Core.Contacts.Tasks;
using MvcMall.Core.Enums;

namespace MvcMall.AdminWeb.Manage.StoreApplies
{
    public partial class StoreList : ManageBasePage
    {
        private IStoreTask _storeTask;

        protected void Page_Load(object sender, EventArgs e)
        {
            ValidatePagePower("StoreList");
            _storeTask = GetInstance<IStoreTask>();
            if (!IsPostBack)
            {
                Bind();
            }
        }

        protected void Bind()
        {
            rptList.DataSource = _storeTask.GetPagedList(ANPager.CurrentPageIndex, ANPager.PageSize, txtUserName.Text, txtPromoteUserName.Text, ddlStoreStatus.SelectedValue == "1" ? StoreStatus.正常 : ddlStoreStatus.SelectedValue == "2" ? StoreStatus.锁定 : (StoreStatus?)null, ddlStoreType.SelectedValue == "1" ? StoreType.个人全职 : ddlStoreType.SelectedValue == "2" ? StoreType.个人兼职 : ddlStoreType.SelectedValue == "3" ? StoreType.有实体店铺 : ddlStoreType.SelectedValue == "4" ? StoreType.公司开店 : (StoreType?)null, txtStoreName.Text.Trim());
            rptList.DataBind();
        }

        protected void ANPager_PageChanged(object sender, EventArgs e)
        {
            Bind();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Bind();
            ANPager.CurrentPageIndex = 1;
        }
    }
}